package Frame.sayoptional;

import FCRendering.FCRMaster;
import VWorldGameStudio.FCPlayerInfo;
import socket.FCRSocketClient;
import socket.FCRSocketServer;
import Function.FCMutilPlayCache;

import java.util.ArrayList;
import java.util.List;

public class PlayerTypeOptional implements ISayoption{


    @Override
    public void clickWhichOption(SayTextAndOption op) {
        FCPlayerInfo p = FCMutilPlayCache.findPlayerByName(op.optionTextId.split(",")[1],op.optionTextId.split(",")[0]);
        if(p == null) return;
        if(op.ctrlType.equals("reborn")){
            if(p.isDeath()){
                p.setBlood(p.getBloodMax());
                p.getLongTermMap().clear();//清除所有状态
                p.setPhysicalnum(p.getPhysical());//恢复体力

                List<FCPlayerInfo> playerInfos = new ArrayList<>(1);
                playerInfos.add(p);
                if(FCRMaster.fcv.isSever()){
                    FCRSocketServer.getIn().syncPlayerState(playerInfos);
                }else if(FCRMaster.fcv.isClient()){
                    FCRSocketClient.getIn().syncPlayerState(playerInfos);
                }
                FCRMaster.fcv.setSayText(new String[]{"mingqisay3-2"});
            }else {
                FCRMaster.fcv.setSayText(new String[]{"mingqisay3-1"});
            }
        }
    }
}
